#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define fr first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x)
{
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x)
{
int f = 0;
cerr << '{';
for (auto &i : x)
cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
ll power(ll base, ll p)
{
ll res = 1;
base = base % M;
while (p > 0)
{
if (p & 1)
{
res = (res * base) % M;
p--;
}
base = (base * base) % M;
p >>= 1;
}
return res;
}
void solve()
{
int n;
cin >> n;
vector<pair<ll, int>> a(n), b(n), c(n);
for (int i = 0; i < n; i++)
{
cin >> a[i].first;
a[i].second = i;
}
for (int i = 0; i < n; i++)
{
cin >> b[i].first;
b[i].second = i;
}
for (int i = 0; i < n; i++)
{
cin >> c[i].first;
c[i].second = i;
}
ll maxi = INT_MIN;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
sort(c.begin(), c.end());
vector<pair<ll, int>> A(3), B(3), C(3);
A[0] = a[n - 1];
A[1] = a[n - 2];
A[2] = a[n - 3];
B[0] = b[n - 1];
B[1] = b[n - 2];
B[2] = b[n - 3];
C[0] = c[n - 1];
C[1] = c[n - 2];
C[2] = c[n - 3];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
if (A[i].second == B[j].second || B[j].second == C[k].second || C[k].second == A[i].second)
{
continue;
}
else
{
maxi = max(maxi, A[i].first + B[j].first + C[k].first);
}
}
}
}
cout << maxi << "\n";
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
mt19937 rng((unsigned int)chrono::steady_clock::now().time_since_epoch().count());
auto start = chrono::high_resolution_clock::now();
int t;
cin >> t;
for (int tc = 1; tc <= t; ++tc)
{
solve();
}
auto stop = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
cerr << duration.count() / 1000.0 << ' ' << 'm' << 's';
return 0;
}
433A - Kitahara Haruki's Gift | 672A - Summer Camp |
1277A - Happy Birthday Polycarp | 577A - Multiplication Table |
817C - Really Big Numbers | 1355A - Sequence with Digits |
977B - Two-gram | 993A - Two Squares |
1659D - Reverse Sort Sum | 1659A - Red Versus Blue |
1659B - Bit Flipping | 1480B - The Great Hero |
1519B - The Cake Is a Lie | 1659C - Line Empire |
515A - Drazil and Date | 1084B - Kvass and the Fair Nut |
1101A - Minimum Integer | 985D - Sand Fortress |
1279A - New Year Garland | 1279B - Verse For Santa |
202A - LLPS | 978A - Remove Duplicates |
1304A - Two Rabbits | 225A - Dice Tower |
1660D - Maximum Product Strikes Back | 1513A - Array and Peaks |
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |